package com.link.base.base.order.dao.mybatis.mapper;

import com.link.base.base.order.model.OrderAmountBoard;
import com.link.base.base.order.model.OrderSaleRank;
import com.link.base.base.order.model.SaleOrder;
import com.link.base.base.product.model.Product;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.model.CallParam;

import java.util.List;

/**
 * @author yrf
 * @date unknown
 * @comments 订单
 */
public interface SaleOrderMapper extends BasicMapper<SaleOrder> {

    /**
     * 计算该订单的总金额
     *
     * @param record 销售订单ID
     * @return 总金额
     * @throws Exception
     */
    public SaleOrder querySaleOrderTotalAmount(SaleOrder record) throws Exception;

    /**
     * 更新订单上的客户
     *
     * @param record
     * @throws Exception
     */
    public void orderAcctIdUpdate(SaleOrder record) throws Exception;

    /**
     * 更新订单状态
     *
     * @param record
     * @return
     * @throws Exception
     */
    public int orderStatusUpdate(SaleOrder record) throws Exception;

    /**
     * 更新提交订单
     *
     * @param record
     * @return
     * @throws Exception
     */
    public void orderCommitUpdate(SaleOrder record) throws Exception;

    /**
     * 更新订单
     *
     * @param record
     * @return
     * @throws Exception
     */
    public void orderNewUpdate(SaleOrder record) throws Exception;

    /**
     * 更新说明
     *
     * @param record
     * @throws Exception
     */
    public void commentsUpdate(SaleOrder record) throws Exception;

    /**
     * 统计
     *
     * @param record
     * @return double
     * @throws Exception
     */
    public Double countTotalCash(SaleOrder record) throws Exception;

    /**
     * 取消订单
     *
     * @param record
     * @throws Exception
     */
    public void cancelSaleOrderUpdate(SaleOrder record) throws Exception;

    /**
     * 插入订单头
     *
     * @param record
     * @return
     * @throws Exception
     */
    public void createHeadInsert(SaleOrder record) throws Exception;

    /**
     * 调用发货完成，存储过程
     *
     * @param record
     * @throws Exception
     */
    public void callOrderComplete(CallParam record) throws Exception;

    /**
     * <p>设置是否已付款标记</p>
     *
     * @author yrf
     * @param order
     * @throws Exception
     */
    public void isPaidUpdate(SaleOrder order) throws Exception;


    /**
     * <p>设置是否已付款标记</p>
     *
     * @author Hlj
     * @param order
     * @throws Exception
     */
    public void payStatusUpdate(SaleOrder order) throws Exception;


    /**
     * 到货确认
     *
     * @param record
     * @return int
     */
    public int arrivedUpdate(SaleOrder record);

    /**
     * <p>买方确认到货</p>
     *
     * @author yrf
     * @param record
     * @return 到货
     */
    public int confirmArrivedUpdate(SaleOrder record);

    /**
     * 查询区域订单情况
     * @param order 定单
     * @return list 订单列表
     * @throws Exception
     */
    public List<SaleOrder> querySalesOrderOfDistrictPage(SaleOrder order) throws Exception;

    /**
     * 查询区域销量情况
     * @param order 定单
     * @return list
     * @throws Exception
     */
    public List<SaleOrder> querySalesOfDistrictPage(SaleOrder order) throws Exception;

    /**
     * 订单记录数统计
     *
     * @param order 订单
     * @return int
     * @throws Exception
     */
    public int selectCountByacctId(SaleOrder order) throws Exception;

    /**
     * 销售额排名
     *
     * @param osr 员工销售额排名
     * @return OrderSaleRank 销售额排名
     * @throws Exception
     */
    public OrderSaleRank orderSaleRank(OrderSaleRank osr) throws Exception;

    /**
     * 查询月销售数据看板
     *
     * @param oad
     * @return OrderAmountBoard 月销售数据看板
     * @throws Exception
     */
    public OrderAmountBoard queryOrderAmountBoard(OrderAmountBoard oad) throws Exception;

    /**
     * 查询月上月份销售数据看板
     *
     * @param oad
     * @return 上月份销售数据看板
     * @throws Exception
     */
    public OrderAmountBoard queryLastMonthOrderAmountBoard(OrderAmountBoard oad) throws Exception;


    /**
     * 付款
     *
     * @param record 订单
     * @throws Exception
     */
    public void orderPayUpdate(SaleOrder record) throws Exception;


    /**
     * 企点新建订单
     * @param record 订单
     * @throws Exception
     */
    public void guideOrderInsert(SaleOrder record) throws Exception;

    /**
     * app dms迁移过来的方法
     * @param record 订单
     * @return int
     * @throws Exception
     */
    public int queryPurchaseMoreByAccntIdCount(SaleOrder record) throws Exception;

    /**
     * 查询购买最多
     *
     * @param record
     * @return 产品列表
     * @throws Exception
     */
    public List<Product> queryPurchaseMoreByAccntId(SaleOrder record) throws Exception;

    /**
     * 无登陆用户下修改订单支付状态
     * @param record
     * @throws Exception
     */
    void orderUpdateByInterface(SaleOrder record) throws Exception;

    /**
     * 查询特定时间内未支付的订单
     * @param saleOrder
     * @return
     * @throws Exception
     */

    List<SaleOrder> queryUnpaidOrder(SaleOrder saleOrder) throws Exception;

    /**
     * 改变订单状态
     * @param order
     * @throws Exception
     */
    void statusUpdate(SaleOrder order) throws Exception;

    /**
     * 未登录修改订单状态
     * @param saleOrder
     * @throws Exception
     */
    void statusUpdateByInterface(SaleOrder saleOrder) throws Exception;

    /**
     * 订单支付后改变该订单的实付金额
     *
     * @author lijie
     * @date 2019/02/27 9:34
     * @param saleOrder 订单需要两个参数：ID和订单实付金额
     * @throws Exception
     */
    void paidinUpdate(SaleOrder saleOrder) throws Exception;
}
